#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define maxn 2005
int n,arr[maxn];

int binarySearch(int arr[],int s,int e,int val){
  int res = e+1;
  while(s<=e){
    int m = s+(e-s)/2;
    if(arr[m]>=val) { 
       res = min(res,m); e = m-1;
    }
    else {
       s = m+1;
    }
  }
  return res;
}

int main(){
   while(true){
     scanf("%d",&n); if(n==0) break;
     for(int i=0;i<n;++i) scanf("%d",&arr[i]); 
     sort(arr,arr+n);
     int res = 0;
     for(int i=0;i<n;++i) 
       for(int j=i+1;j<n;++j){
           res += n-binarySearch(arr,j+1,n-1,arr[i]+arr[j]+1);
       }
     printf("%d\n",res);  
   }
   return 0;
}